//
//  STProDetailListView.m
//  YiYueHairdresser
//
//  Created by zhouzhouzhou on 2018/10/12.
//  Copyright © 2018年 YuYiLian. All rights reserved.
//

#import "STProDetailListView.h"
#import "STProDetailView.h"

@implementation STProDetailListView


-(void)setProDetailImgListViewWithArr:(NSArray *)arrPros{
    arrImgPros = arrPros;
    [self loadProImgListView];
}


-(void)loadProImgListView{
    if(!detailListView){
        detailListView= [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
        detailListView.delegate = self;
        detailListView.dataSource = self;
        detailListView.pagingEnabled = YES;
        detailListView.separatorStyle = UITableViewCellSelectionStyleNone;
        detailListView.showsVerticalScrollIndicator = NO;
        detailListView.backgroundColor = [UIColor clearColor];
        detailListView.tableFooterView = [UIView new];
        detailListView.rowHeight = SCREEN_HEIGHT-64-60;
        [self addSubview:detailListView];
    }else{
        [detailListView reloadData];
    }
        
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return arrImgPros.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString * identifier = @"imgDetailCell";
//    UITableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:identifier];
//    if (!cell) {
    UITableViewCell *  cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
    NSDictionary * dic = arrImgPros[indexPath.row];
    STProDetailView * detailView = [[STProDetailView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, SCREEN_HEIGHT-64-60)];
    [detailView setProDetailViewWithDicData:dic];
    [cell.contentView addSubview:detailView];
    
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.delegate respondsToSelector:@selector(proDetailListViewProImgScrollToNum:)]) {
        [self.delegate proDetailListViewProImgScrollToNum:indexPath.row];
    }
}

@end
